#!/usr/bin/env python3

import argparse
import pulp_config as plpconf
import os

parser = argparse.ArgumentParser(description='Generate PC debug info')

parser.add_argument("--input", dest="input", default=None, help="Specify input file")
parser.add_argument("--output", dest="output", default=None, help="Specify output file")
parser.add_argument("--config", dest="config", default=None, help="Specify config")

args = parser.parse_args()


config = plpconf.get_config_from_tag(args.config)

l2_size = config.get_str('**/l2/size')


try:
    os.makedirs(os.path.dirname(args.output))
except:
    pass

with open(args.output, 'w') as output_file:
  with open(args.input) as input_file:

    script = input_file.read()

    script = script.replace('@l2_size@', l2_size)

    output_file.write(script)